<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			var myDate = new Date();
			console.log(myDate.getFullYear());
			console.log(myDate.getMonth());
			console.log(myDate.getDate());
			console.log(myDate.getDay());
		</script>
	</head>
	<body>
		<b>年</b><b>月</b><b>日</b><b>星期</b>
	</body>
	<script type="text/javascript">
		//获取元素
		var oldB = document.getElementsByTagName("b");
		var year = myDate.getFullYear();
		var month = myDate.getMonth();
		var Date = myDate.getDate();
		var day = myDate.getDay();
		//创建新元素
		var newB = document.createElement("b");
		//获取时间
		year = document.createTextNode(year);
		month = document.createTextNode(month);
		Date = document.createTextNode(Date);
		day = document.createTextNode(day);	
		//插入
		newB.appendChild(year);
		oldB[0].insertBefore(year,oldB[0].childNodes[0]);
		newB.appendChild(month);
		oldB[1].insertBefore(month,oldB[1].childNodes[0]);
		newB.appendChild(Date);
		oldB[2].insertBefore(Date,oldB[2].childNodes[0]);
		newB.appendChild(day);
		oldB[3].appendChild(newB);
		
		
	</script>
</html>
